package pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/*
演示线程池常用的三种分类
 */
public class ThreadPoolDemo1 {

  public static void main(String[] args) {

//    一池N个线程:newFixedThreadPool
    ExecutorService executorService = Executors.newFixedThreadPool(5);
    try{
      for (int i = 0; i < 10; i++) {
        executorService.execute(()->{
          System.out.println(Thread.currentThread().getName() + "办理业务");
        });
      }
    }catch (Exception e){
      e.printStackTrace();
    }finally {
      executorService.shutdown();
    }

  }
}
